package com.he.pojo;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Signin extends Page{
    private Integer id;

    private Integer userId;

    private String userName;

    private Byte isUp;

    private Date signinDate;

    private Date signinUp;
    
    private String upTime;

    private String ipUp;

    private Date signinDown;
    
    private String downTime;

    private String ipDown;

    private String date;
    
    private String workTime;
    
    
    public String getWorkTime() {
    	long nd = 1000 * 24 * 60 * 60;
    	long nh = 1000 * 60 * 60;
    	long nm = 1000 * 60;
    	long ns = 1000;
    	if(signinDown!=null) {
    		long diff = signinDown.getTime()-signinUp.getTime();
    		long hour = diff % nd / nh;
    		long min = diff % nd % nh / nm;
    		long sec = diff % nd % nh % nm / ns;
    		workTime=String.valueOf(hour)+"小时"+String.valueOf(min)+"分钟"+String.valueOf(sec)+"秒";
    	}
		return workTime;
	}

	public void setWorkTime(String workTime) {
		this.workTime = workTime;
	}

	public String getUpTime() {
    	if(signinUp!=null) {
	    	SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss");
	    	upTime = sdf.format(signinUp);
    	}
		return upTime;
	}

	public void setUpTime(String upTime) {
		
		this.upTime = upTime;
	}

	public String getDownTime() {
		if(signinDown!=null) {
			SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss");
	    	downTime = sdf.format(signinDown);
		}
		return downTime;
	}

	public void setDownTime(String downTime) {
		this.downTime = downTime;
	}

	public String getDate() {
		if(signinDate!=null) {
	    	SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	    	date = sdf.format(signinDate);
		}
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName == null ? null : userName.trim();
    }

    public Byte getIsUp() {
        return isUp;
    }

    public void setIsUp(Byte isUp) {
        this.isUp = isUp;
    }

    public Date getSigninDate() {
        return signinDate;
    }

    public void setSigninDate(Date signinDate) {
        this.signinDate = signinDate;
    }

    public Date getSigninUp() {
        return signinUp;
    }

    public void setSigninUp(Date signinUp) {
        this.signinUp = signinUp;
    }

    public String getIpUp() {
        return ipUp;
    }

    public void setIpUp(String ipUp) {
        this.ipUp = ipUp == null ? null : ipUp.trim();
    }

    public Date getSigninDown() {
        return signinDown;
    }

    public void setSigninDown(Date signinDown) {
        this.signinDown = signinDown;
    }

    public String getIpDown() {
        return ipDown;
    }

    public void setIpDown(String ipDown) {
        this.ipDown = ipDown == null ? null : ipDown.trim();
    }
}